<template>
	<view class="suborder-item" v-if="subOrderDetail">
		<view class="suborder-item-top-wrapper">
			<view class="goods-name">
				{{subOrderDetail.product_name}}
			</view>
			<view class="device-info">
				<view class="device-number" @click="copy">
					机器号：{{subOrderDetail.model_sn}} <i class="iconfont icon-copy"/>
				</view>
				<view class="device-count">
				
				</view>
			</view>
		</view>
		<view class="suborder-item-bottom-wrapper">
			<view class="suborder-number">
				子单号：{{subOrderDetail.suborder_no}}
			</view>
			<view class="total-price">
				￥{{singlePrice}}
			</view>
		</view>
	</view>	
</template>

<script lang="ts" setup>
	import {ISubOrderDetail} from '../../types';
	import { defineProps } from 'vue';
	
	interface IProps{
		subOrderDetail:ISubOrderDetail|null;
		singlePrice:string;
	}
	
	const props = withDefaults(defineProps<IProps>(),{
		subOrderDetail:null
	})
	
	const copy = ()=>{
		uni.setClipboardData({
			data: props.subOrderDetail!.model_sn,
			success: ()=> {
				uni.prompt.$showToast('已复制机器编号')
			}
		});
	}
</script>

<style scoped lang="scss">
	@import "./suborderItem.scss";
</style>